﻿Public Class Weather

    Public Property Pressure As Decimal
    Public Property Temperature As Decimal
    Public Property Frozen As Decimal

    Public Sub Load(stream As IO.StreamReader)

        Dim shouldExit As Boolean = False
        Dim data As LineData

        Do Until shouldExit OrElse stream.EndOfStream
            data = ReadLineData(stream)

            Select Case data.LineType
                Case DataLineType.KeyValue
                    Select Case data.KeyValueData.Key
                        Case "pressure"
                            Pressure = data.KeyValueData.Value.ToDecimal
                        Case "temperature"
                            Temperature = data.KeyValueData.Value.ToDecimal
                        Case "frozen"
                            Frozen = data.KeyValueData.Value.ToDecimal
                        Case Else
                            AddUnmanagedLine(data.OriginalText)
                    End Select
                Case DataLineType.StarBlockChar
                Case DataLineType.EndBlockChar
                    shouldExit = True
            End Select
        Loop
    End Sub

End Class
